<?php


$p_id=$_GET["id"];
$page_no=$_GET["page"];
if(!$page_no>0) $page_no=1;
$p_id = preg_replace("/^http:\/\/(.+)\/xys\//","",$p_id);


if(preg_match("/zip$/",$p_id)) {

$file = preg_replace("/(.*\/)/","",$p_id);

header("Content-Type: application/zip \n");
header("Content-Description: zip file of latest xys articles\n");
header("Content-Disposition: attachment; filename=${file}\n\n");

  $fh=fopen("http://www.xys.org/xys/$p_id","r");
  while(!feof($fh)) echo fread($fh, 200000);
  fclose($fh);

exit(0);

}

if(preg_match("/pdf$/",$p_id)) {

$file = preg_replace("/(.*\/)/","",$p_id);

header("Content-Type: application/pdf\n");
header("Content-Description: pdf file of latest xys articles\n");
header("Content-Disposition: attachment; filename=${file}\n\n");

  $fh=fopen("http://www.xys.org/xys/$p_id","r");
  while(!feof($fh)) echo fread($fh, 200000);
  fclose($fh);

exit(0);
}

include("../lib/db.lib");
include("../lib/std.lib");

$shop_id=3;
$title=product_get_title($shop_id,$p_id);
$title=gb2utf8($title);

?>

<html>
<head>
<meta http-equiv="Content-Type"   content="text/html; charset=UTF-8">

<title><?php echo  $title; ?> </title></head>
    <frameset rows="*,0" border=0>
        <frame src="./read.html?id=<?php echo $p_id; ?>&page=<?php echo $page_no;?>" name="down">
        <frame src="read_up.php?id=<?php echo $p_id; ?>" name="up">
    </frameset>
    <noframes>
    Click <a href="<?php echo $base_url."/xys/".$p_id; ?>"">here</a> to see it.
    </noframes>
</html>
